<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/commons/inc.jsp" %>

<h3 id="navTitleId">临床分组设定</h3>

<body id="body">

<script>
function showSel(){
	var c = '<s:property value='researchGroup.content'/>';
	var list = '<s:property value='tbList'/>';
	if(list !=null){
		var size= '<s:property value='tbList.size()'/>';
		if(size>0){
			if(c!=null && c!=''){
				c = c.split(",");
				for(var i=0;i<c.length;i++){
					if($('name'+c[i].trim())){
						$('name'+c[i].trim()).checked = true;
					}			
				}
			}
		}
	}	
}
</script>

<%@include file="/commons/showmessage.jsp" %>

<form name="groupform" id="groupform" method="post" action="${contextPath}/group/group.action?method=saveEditGroup">
	<s:hidden name="researchGroup.researchgroupid" id="researchGroup.researchgroupid"></s:hidden>
	<s:hidden name="researchGroup.groupstatus" id="researchGroup.groupstatus"></s:hidden>
	<s:hidden name="researchGroup.parentgroup" id="researchGroup.parentgroup"></s:hidden>
	<s:hidden name="researchGroup.patientcount" id="researchGroup.patientcount"></s:hidden>
	<s:hidden name="researchgroupid" id="researchgroupid"></s:hidden>
	<table>
		<tr>
			<td class="tdLabel"><label class="label">临床组别:</label></td>
			<td class="tdLabel"><label class="label">编号:</label>
				<input type="text" name="researchGroup.groupbh" maxlength="20" size="4" id="researchGroup.groupbh" value="${researchGroup.groupbh}" dataType="Noempty" msg="请输入课题名称编号" disabled="true"/></td>
			<td class="tdLabel"><label class="label">填写内容：</label>
				<input type="text" name="researchGroup.groupname" maxlength="100" id="researchGroup.groupname" value="${researchGroup.groupname}" dataType="Noempty" msg="请输入课题名称填写内容" disabled="true"/></td>	
		 </tr>
	 </table>
	 <s:if test="researchGroup.researchgroupid!=1 && researchGroup.parentgroup==0">
		<table>
			 <tr>
				<td class="tdLabel"><label class="label">干预因素:</label></td>
				<td>
					<table id="addtb">
						<tr>
							<td> 
							<s:if test="subGroups!=null && subGroups.size()>0">
							<table id="addtb">
							<s:iterator value="#request.subGroups" id="ind" status="st">
								<tr><td><s:property value="#st.index+1"/>.
								<a href="javascript:;" onclick="gotosub(${researchgroupid})">${groupbh}-${groupname}</a></td>
								</tr>
							</s:iterator>
							</table>
							</s:if>
							</td>
						</tr>
						<tr>
							<td><a href="javascript:;" onclick="addTable('addtb','groupbh','groupname')">增加</a></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</s:if>
	<table>
	<tr>
		<td class="tdLabel"><label class="label">随访周期:</label></td>
		<td><input type="text" name="researchGroup.timelong" size="5" id="researchGroup.timelong" value="${researchGroup.timelong}" disabled="true"/>
			<select name="researchGroup.timetype" id="researchGroup.timetype" disabled="true">
					<option value="0" <s:if test="researchGroup.timetype == 0">selected</s:if>>天</option>
					<option value="1" <s:if test="researchGroup.timetype == 1">selected</s:if>>月</option>
					<option value="2" <s:if test="researchGroup.timetype == 2">selected</s:if>>年</option>
			</select></td> 
	</tr>
	<tr>
		<td class="tdLabel"><label class="label">状态:</label></td>
		<td><select name="researchGroup.groupstatus" id="researchGroup.groupstatus">
					<option value="0" <s:if test="researchGroup.groupstatus == 0">selected</s:if>>进行中</option>
					<option value="1" <s:if test="researchGroup.groupstatus == 1">selected</s:if>>结束</option>
			</select></td> 
	</tr>
	
	</table>
	
	<s:if test="researchGroup.researchgroupid>1">
		<div id="emptyPara" style="height:30px;"></div>
		<table>
			<tr>
				<td class="tdLabel"><label class="label">调查内容:</label></td>
				<table class="formTable" border="0" cellspacing="1" cellpadding="0" width="65%" >
					<tr>
						<td class="form-td"><label class="label"><b>初始信息:</b></label></td>  
						<td class="form-td">
							<table>
								<tr>
									<td>
										<input type="checkbox" name="researchGroup.content" id="name5" value="5" disabled="true"/><font style="vertical-align:bottom;">其他病症</font>
									</td>
								</tr>
								<tr>
									<td><input type="checkbox" name="researchGroup.content" id="name6" value="6" disabled="true"/><font style="vertical-align:bottom;">体格测试</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name7" value="7" disabled="true"/><font style="vertical-align:bottom;">血糖指标</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name8" value="8" disabled="true"/><font style="vertical-align:bottom;">血脂指标</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name9" value="9" disabled="true"/><font style="vertical-align:bottom;">胰岛功能</font></td>
								</tr>
								<tr>	
									<td><input type="checkbox" name="researchGroup.content" id="name10" value="10" disabled="true"/><font style="vertical-align:bottom;">血常规</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name11" value="11" disabled="true"/><font style="vertical-align:bottom;">肝肾功能</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name12" value="12" disabled="true"/><font style="vertical-align:bottom;">尿液检查</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name14" value="14" disabled="true"/><font style="vertical-align:bottom;">其他指标</font></td>
								</tr>	
								<tr>
									<td><input type="checkbox" name="researchGroup.content" id="name15" value="15" disabled="true"/><font style="vertical-align:bottom;">运动调查</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name17" value="17" disabled="true"/><font style="vertical-align:bottom;">营养调查</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name25" value="25" disabled="true"/><font style="vertical-align:bottom;">药物调查</font></td>
								</tr>
								<tr>
									<td><input type="checkbox" name="researchGroup.content" id="name20" value="20" disabled="true"/><font style="vertical-align:bottom;">证候调查</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name21" value="21" disabled="true"/><font style="vertical-align:bottom;">体质调查</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name22" value="22" disabled="true"/><font style="vertical-align:bottom;">生存质量</font></td>					  			 
								</tr>
							</table>						
						</td>
					</tr>
					
					
					<tr height="10"></tr>
					<tr>
						<td class="form-td"><label class="label"><b>治疗信息:</b></label></td>	 
						<td class="form-td">
							<table>
								<tr>
									<td><input type="checkbox" name="researchGroup.content" id="name24" value="24" disabled="true"/><font style="vertical-align:bottom;">运动治疗</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name18" value="18" disabled="true"/><font style="vertical-align:bottom;">营养治疗</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name19" value="19" disabled="true"/><font style="vertical-align:bottom;">药物治疗</font></td>
								</tr>
							</table>
						</td>							
					</tr>
					
					<tr height="10"></tr>
					<tr>
						<td class="form-td"><label class="label"><b>随访信息:</b></label></td>
						<td class="form-td">
							<table>
								<tr>
									<td><input type="checkbox" name="researchGroup.content" id="name23" value="23" disabled="true"/><font style="vertical-align:bottom;">检验随访</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name29" value="29" disabled="true"/><font style="vertical-align:bottom;">营养随访</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name16" value="16" disabled="true"/><font style="vertical-align:bottom;">运动随访</font></td>	
									<td><input type="checkbox" name="researchGroup.content" id="name26" value="26" disabled="true"/><font style="vertical-align:bottom;">药物调整</font></td>
								</tr>
								<tr>
									<td></td>	
									<td><input type="checkbox" name="researchGroup.content" id="name27" value="27" disabled="true"/><font style="vertical-align:bottom;">证候调查</font></td>
									<td><input type="checkbox" name="researchGroup.content" id="name28" value="28" disabled="true"/><font style="vertical-align:bottom;">生存质量</font></td>	
								</tr>
							</table>
						</td>		
					</tr>					
				</table> 
					<script>showSel()</script>
				</table> 	
			</tr>
		</table>
	</s:if>
	<table>
	<tr>
		<td align="center">
		<input type="button" onclick="saveEdit('save');" value="保存">
		<input type="button" onclick="javascript:back();"value="返回列表"></td>
	</tr>
</table>
</form>

</body>

<style type="text/css">
body {
	height: 100%;
	width: 100%;
}
</style>

<script>
function back(){
	location.href="${contextPath}/group/group.action?method=query";
}
function gotosub(id){
	location.href="${contextPath}/group/group.action?method=editGroup&researchgroupid="+id;
	 
}
function saveEdit(type){
	if(type=='refresh'){
		location.reload();
	}else if(type=='save'){
		if(!Validator.Validate($('groupform'),3)){
			return;
		}	
		/*var id = '<s:property value='researchGroup.researchgroupid'/>';
		if(id!=null){
			if(id>1){
				var list = '<s:property value='tbList'/>';
				if(list !=null){
					var size= '<s:property value='tbList.size()'/>';
					var flag=false;
					for(var i=0;i<=size;i++){		 	 
						if($('name'+i) && $('name'+i).checked){
							flag=true;
							break;
						}		
					} 
					if(!flag){
						alert("请选择调查内容");
						return;
					}
				}
			}
		}*/
		$('groupform').submit();
	}
}
var addCount=5;
function addTable(tbid,groupbh,groupname){
    var oTable = $(tbid);//取得table
    var oTBody = oTable.tBodies[0];
    var oRows = oTBody.rows;
    if(oRows.length > (typeof(addCount)=="undefined" ? 3:addCount)) return;
    var newGroupName = "list"+(oRows.length);
    
    var newTr = document.createElement("TR");
    var newTd1 = document.createElement("TD");
    var newTd2 = document.createElement("TD");
	var newTd3 = document.createElement("TD");
	 
	newTd1.style.background="#FFFFFF";
	newTd2.style.background="#FFFFFF";
	newTd3.style.background="#FFFFFF";
  
    newTd1.onclick=function(){deleTable(newGroupName,tbid);};
    newTd1.className = "TdStyle";  					
    newTd1.innerHTML = "-";    
    newTd2.setAttribute("align","left");   
    newTd2.innerHTML="<label class='label'>编号:</label><input type='text' name='"+groupbh+"' size='4' maxlength='20' dataType='Noempty' msg='请输入编号'>";  
    newTd3.innerHTML="<label class='label'>填写内容：</label><input  type='text' name='"+groupname+"' maxlength='100' dataType='Noempty' msg='请输入填写内容'/>";

    newTr.appendChild(newTd1);
    newTr.appendChild(newTd2);
	newTr.appendChild(newTd3);
    newTr.setAttribute("id",newGroupName);
    oTBody.appendChild(newTr); 
}
   
function deleTable(groupName,tbid){
    var oTable = $(tbid);
    var oTBody = oTable.tBodies[0];
    for(var i=0; i<oTBody.rows.length; i++){
	      var TrId = oTBody.rows[i].getAttribute("id");
	      if(TrId == groupName){
	      	 oTBody.deleteRow(i);
	       	break;
	      }
    }
}
</script>